// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: wsfuyibing <682805@qq.com>
// Date: 2024-11-12

package base

import "strings"

// Tracer
// 链路适配, 定义链路追踪数据上报到哪里, 内置支持下列类型.
type Tracer string

const (
	TracerNone   Tracer = ""       // 1. 不上报
	TracerJaeger Tracer = "jaeger" // 2. 上报到Jaeger (https://www.jaegertracing.io/)
	TracerZipkin Tracer = "zipkin" // 3. 上报到Zipkin (https://zipkin.io/)
)

// Defaulter
// 计算默认值.
func (o Tracer) Defaulter() Tracer {
	v := Tracer(strings.ToLower(o.String()))
	switch v {
	case TracerJaeger, TracerZipkin:
		return v
	}
	return TracerNone
}

// IsNone
// 是否未定义.
func (o Tracer) IsNone() bool {
	return o == TracerNone
}

// String
// 转成字符串.
func (o Tracer) String() string {
	return string(o)
}
